﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using carShopControl.BLL;

namespace carShopControl.DAL
{
    class SanPhamDAL
    {
        internal static List<carShopControl.BLL.SanPhamBLL> GetAll()
        {
            var sanphams = from sp in CommonDAL.CarShopDB.SanPhams
                           select new SanPhamBLL()
                           {
                               ID = sp.ID,
                               MaSanPham = sp.MaSanPham,
                               TenSanPham = sp.TenSanPham,
                               SoTon = sp.SoTon==null?0:(int)sp.SoTon,
                               Anh = sp.Anh,
                               BaoHanh = sp.BaoHanh,
                               Gia = (decimal)sp.Gia,
                               MoTa = sp.MoTa,
                               LoaiSanPham = LoaiSanPhamDAL.GetByID(sp.ID)
                           };
            return sanphams.ToList<SanPhamBLL>();
        }
    }
}
